package com.glance.browser.dao;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.glance.browser.domain.KnowledgeClass;
import com.glance.browser.repository.KnowledgeClassRepository;

@Repository
@Transactional(readOnly = true)
public class KnowledgeClassDAOImpl implements KnowledgeClassDAO{

	@Autowired
	private KnowledgeClassRepository repository;

	public List<KnowledgeClass> findByTitle(String title) {
		return repository.findByTitle(title);
	}
	
	public List<KnowledgeClass> findByOwner(String username) {
		return repository.findByOwner(username);
	}

	public KnowledgeClass findById(Long id) {
		return repository.findOne(id);
	}

	@Transactional
	public KnowledgeClass save(KnowledgeClass knowledgeClass) {
		return repository.save(knowledgeClass);
	}

	@Transactional
	public void delete(KnowledgeClass knowledgeClass) {
		repository.delete(knowledgeClass);
	}
}
